<HTML> 
<HEAD> 
	<TITLE>3rd Party ROBOTC Drivers</TITLE> 
<link href="tabs.css" rel="stylesheet" type="text/css"/> 
<link href="doxygen.css" rel="stylesheet" type="text/css"/> 
</HEAD> 
 
<BODY bgcolor="#ffffff" link="#000000" vlink="#000000"> 
<table width="100%" bgcolor="navy" cellspacing=0 cellpadding=1 border=0> 
<tr><td><table width="100%" bgcolor="#EEEEDD" cellspacing=0 cellpadding=3 border=0> 
<tr> 
    <td width="33%" align="left"> <img src="images/LOGO_NXT.gif" width=266 height=44 border="0" alt="Mindstorms"></td> 
    <td><b><font size="+3" color="navy">3rd Party ROBOTC Drivers</font></b></td> 
    <td align="right"> <img src="images/logo.png" width=44 height=44 border="0" alt="RobotC"></td>     
</tr> 
  <tr bgcolor="#cccc99" align="right"> 
          <td colspan=3> <font face="arial" size="-1"> [<a href=main.html>Home</a>] [<a target=_top href="https://sourceforge.net/projects/rdpartyrobotcdr/">Download</a>] [<a target=_top href="http://apps.sourceforge.net/mantisbt/rdpartyrobotcdr/my_view_page.php">Submit a bug/suggestion</a>]  [<a target=_top href="http://www.robotc.net/forums/">ROBOTC Forums</a>] [<a target=_top href="http://botbench.com">Blog</a>] [<a target=_top href="http://sourceforge.net/donate/index.php?group_id=257238">Support this project</a>]</font> </td> 
</tr> 
</table></td></tr> 
</table> 
<!-- Generated by Doxygen 1.7.2 -->
<div class="header">
  <div class="headertitle">
<h1>mindsensors-rcxmotormux-test1.c</h1>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="preprocessor">#pragma config(Sensor, S1,     MSMTRMX,             sensorI2CCustomFastSkipStates)</span>
<span class="preprocessor"></span><span class="comment">//*!!Code automatically generated by &#39;ROBOTC&#39; configuration wizard               !!*//</span>

<span class="comment">/*</span>
<span class="comment"> * $Id: mindsensors-rcxmotormux-test1.c 133 2013-03-10 15:15:38Z xander $</span>
<span class="comment"> */</span>
<span class="comment"></span>
<span class="comment">/**</span>
<span class="comment"> * mindsensors-rcxmotormux.h provides an API for the Mindsensors RCX Motor MUX.</span>
<span class="comment"> * This program demonstrates how to use the driver for the Mindsensors RCX Motor Mux.</span>
<span class="comment"> * Plug the mux into sensor port 1, and a motor into motor output 1. The motor will</span>
<span class="comment"> * gradually speed up to full power and then back again, and then the same backwards.</span>
<span class="comment"> * It will then gradually increase the braking force from nothing to full power, and</span>
<span class="comment"> * back to zero, before turning the motor off</span>
<span class="comment"> *</span>
<span class="comment"> * Changelog:</span>
<span class="comment"> * - 0.1: Initial release</span>
<span class="comment"> *</span>
<span class="comment"> * License: You may use this code as you wish, provided you give credit where it&#39;s due.</span>
<span class="comment"> *</span>
<span class="comment"> * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER. </span>
<span class="comment"></span>
<span class="comment"> * Daniel Playfair Cal (daniel.playfair.cal_at_gmail.com)</span>
<span class="comment"> * 20 September 2011</span>
<span class="comment"> * version 0.1</span>
<span class="comment"> */</span>

<span class="preprocessor">#include &quot;<a class="code" href="mindsensors-rcxmotormux_8h.html" title="RobotC Mindsensors RCX Motor MUX Driver.">drivers/mindsensors-rcxmotormux.h</a>&quot;</span>

task main () {

  <span class="comment">// Gradually speed up</span>
  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> power = 0; power &lt;= 255; power++) {
    <a name="a0"></a><a class="code" href="group__msmtrmx.html#ga9d123ef3b2b23693ca20680d36039eab">MSMTRMX_Control</a> (MSMTRMX, <a name="a1"></a><a class="code" href="group__msmtrmx.html#ggac6569ab3e3f6a2aa0bd679d2a18b36c5a64f2d42d079c42b6c817dd6a197c7f44">MSMTRMX_M1</a>, power);
    wait1Msec (20);
  }

  <span class="comment">// Gradually slow down</span>
  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> power = 255; power &gt;=1; power--) {
    <a class="code" href="group__msmtrmx.html#ga9d123ef3b2b23693ca20680d36039eab">MSMTRMX_Control</a> (MSMTRMX, <a class="code" href="group__msmtrmx.html#ggac6569ab3e3f6a2aa0bd679d2a18b36c5a64f2d42d079c42b6c817dd6a197c7f44">MSMTRMX_M1</a>, power);
    wait1Msec (20);
  }

  <span class="comment">// The same backwards</span>
  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> power = 0; power &gt;= -255; power--) {
    <a class="code" href="group__msmtrmx.html#ga9d123ef3b2b23693ca20680d36039eab">MSMTRMX_Control</a> (MSMTRMX, <a class="code" href="group__msmtrmx.html#ggac6569ab3e3f6a2aa0bd679d2a18b36c5a64f2d42d079c42b6c817dd6a197c7f44">MSMTRMX_M1</a>, power);
    wait1Msec (20);
  }

  <span class="comment">// Slow down again</span>
  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> power = -255; power &lt;= -1; power++) {
    <a class="code" href="group__msmtrmx.html#ga9d123ef3b2b23693ca20680d36039eab">MSMTRMX_Control</a> (MSMTRMX, <a class="code" href="group__msmtrmx.html#ggac6569ab3e3f6a2aa0bd679d2a18b36c5a64f2d42d079c42b6c817dd6a197c7f44">MSMTRMX_M1</a>, power);
    wait1Msec (20);
  }

  <span class="comment">// Gradually increase braking force</span>
  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> force = 0; force &lt;= 255; force++) {
    <a name="a2"></a><a class="code" href="group__msmtrmx.html#ga715a0828ba4632b83617903093132021">MSMTRMX_Brake</a> (MSMTRMX, <a class="code" href="group__msmtrmx.html#ggac6569ab3e3f6a2aa0bd679d2a18b36c5a64f2d42d079c42b6c817dd6a197c7f44">MSMTRMX_M1</a>, force);
    wait1Msec (20);
  }

  <span class="comment">// Gradually reduce braing force</span>
  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> force = 255; force &gt;=1; force--) {
    <a class="code" href="group__msmtrmx.html#ga715a0828ba4632b83617903093132021">MSMTRMX_Brake</a> (MSMTRMX, <a class="code" href="group__msmtrmx.html#ggac6569ab3e3f6a2aa0bd679d2a18b36c5a64f2d42d079c42b6c817dd6a197c7f44">MSMTRMX_M1</a>, force);
    wait1Msec (20);
  }

  <span class="comment">// Turn off the motor</span>
  <a class="code" href="group__msmtrmx.html#ga9d123ef3b2b23693ca20680d36039eab">MSMTRMX_Control</a> (MSMTRMX, <a class="code" href="group__msmtrmx.html#ggac6569ab3e3f6a2aa0bd679d2a18b36c5a64f2d42d079c42b6c817dd6a197c7f44">MSMTRMX_M1</a>, 0);
}
</pre></div> </div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Wed Mar 13 2013 19:56:42 for ROBOTC Drivers by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
</body>
</html>
